package org.bluedream.core.module.dao.emp;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.bluedream.core.module.entity.emp.Emp;

import java.io.Serializable;

/**
 * @ClassName EmpDao
 * @Description TODO
 * @Author Administrator
 * @Data 10:15
 * @Version
 */
public interface EmpDao extends BaseMapper<Emp> {

    @Override
    @Select("select depItem.code as \"depItem.treeCode\" , depItem.tree_name as \"depItem.treeName\", " +
            " depItem.tree_name as depName , emp.* " +
            " from t_emp emp , tDepItem depItem " +
            " ${ew.customSqlSegment} and emp.status = '0' and depItem.status = '0' and emp.dep_code = depItem.code")
    IPage<Emp> selectPage(IPage<Emp> page, @Param("ew") Wrapper<Emp> queryWrapper);

    @Override
    @Select("select depItem.code as \"depItem.treeCode\" , depItem.tree_name as \"depItem.treeName\", " +
            " depItem.tree_name as depName , emp.* " +
            " from t_emp emp , tDepItem depItem " +
            " ${ew.customSqlSegment} and emp.status = '0' and depItem.status = '0' and emp.dep_code = depItem.code")
    Emp selectOne(@Param("ew")Wrapper<Emp> queryWrapper);

    @Override
    @Select("select depItem.code as \"depItem.treeCode\" , depItem.tree_name as \"depItem.treeName\", " +
            " depItem.tree_name as depName , emp.* " +
            " from t_emp emp , tDepItem depItem " +
            " where emp.id = #{id} and emp.status = '0' and depItem.status = '0' and emp.dep_code = depItem.code")
    Emp selectById(@Param("id") Serializable id);
}
